package com.jintu.portal.repository.mysql.dao;

import com.jintu.portal.repository.mysql.mapper.ScoreCardMapper;
import com.jintu.portal.pojo.entity.mysql.ScoreCard;
import com.jintu.portal.pojo.exception.DaoException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;

/**
 * @author very
 */
@Slf4j
@Repository("scoreCardDao")
public class ScoreCardDao {

    @Resource
    private ScoreCardMapper scoreCardMapper;

    public ScoreCard queryMyselfScoreCardByCode(String scoreCardCode, Integer userId) throws DaoException {
        try {
            return scoreCardMapper.queryMyselfScoreCardByCode(scoreCardCode, userId);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }

    public ScoreCard queryOthersScoreCardByCode(String scoreCardCode, String username) throws DaoException {
        try {
            return scoreCardMapper.queryOthersScoreCardByCode(scoreCardCode, username);
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            throw new DaoException(e.getMessage());
        }
    }
}
